package cn.com.lms.business.organization.persistence.repository;

import com.bnzj.cloud.business.core.persistence.entity.SysUser;
import com.bnzj.core.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface BasSupplierUserRepository extends BaseRepository<SysUser, Long> {

    @Query(value = "SELECT d.id, d.account, d.cname, d.email, d.sex, d.phone, d.ename, d.dept_id, d.password, d.full_dept_name, c.name position,d.remarks, "
            + "d.position as position_id, d.personnel, d.enabled, d.creator, d.create_time, d.modify_by, d.modify_time, d.creator_name,  "
            + "d.modify_name, d.v_dept_full_name, d.type, d.link_id,b.id as supplier_id,b.name as supplier_name FROM bnz_sys_user d join bnz_bas_supplier b  "
            + "on d.link_id=b.id  left join bnz_sys_dictionary c on c.id=d.position where d.type=\"B\"  and d.link_id=b.id and d.id =?1", nativeQuery = true)
    Optional<SysUser> findBasSupplierUserById(Long id);

}
